package com.group3.pojo.receive;

import com.group3.controller.Validated.*;
import com.group3.domain.Teacher;
import com.group3.pojo.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

/**
 * @author 王林
 * @version 1.0
 * @date 2021-06-17 周四
 * @time 15:59
 * @description
 */
@Data
@ApiModel(value = "教师信息")
public class TeacherReceive extends Page {

    @NotEmpty(message = "教师工号不能为空", groups = {Add.class})
    @ApiModelProperty(value = "修改后的教师工号")
    private String teacherId;

    @NotEmpty(message = "修改后的教师工号不能为空！", groups = {Update.class})
    @ApiModelProperty(value = "原来的教师工号")
    private String beforeTeacherId;

    @NotEmpty(message = "教师姓名不能为空", groups = {Add.class})
    @ApiModelProperty(value = "教师姓名")
    private String teacherName;

//    @NotEmpty(message = "教师性别不能为空", groups = {Add.class})
    @Max(value = 1, message = "1表示为女", groups = {Add.class})
    @Min(value = 0, message = "0表示为男", groups = {Add.class})
    @ApiModelProperty(value = "教师性别")
    private Integer sex;

    @NotEmpty(message = "教师身份证号不能为空", groups = {Add.class})
    @IdCard(groups = {Add.class})
    @ApiModelProperty(value = "教师身份证号")
    private String cardId;

    @NotEmpty(message = "教师职位不能为空", groups = {Add.class})
    @ApiModelProperty(value = "教师职位")
    private String position;

    @NotEmpty(message = "教师电话号码不能为空", groups = {Add.class})
    @Phone(message = "电话格式有问题")
    @ApiModelProperty(value = "教师电话号码")
    private String tel;

    public Teacher getTeacher(){
        //TODO  突然意识到的问题，可以在自己写的类里面来持有类。不去修改自动生成的类
        Teacher teacher = new Teacher();

        teacher.setTeacherId(this.getTeacherId());
        teacher.setTeacherName(this.getTeacherName());
        teacher.setSex(this.getSex());
        teacher.setCardId(this.getCardId());
        teacher.setPosition(this.getPosition());
        teacher.setTel(this.getTel());

        return teacher;
    }
}
